package com.smartticket.jeju.service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.smartticket.jeju.model.Sight;
import com.smartticket.jeju.model.Ticket;
import com.smartticket.jeju.repository.SightRepository;

@Service
public class SightServiceImpl implements SightService 
{
	@Autowired
	private SightRepository sightRepository;

	public Sight get(int id) 
	{
		return sightRepository.findById(id);
	}

	public Map<Integer, String> getSightNameWithTicket(List<Ticket> tickets) {
		Map<Integer, String> sightNameMap = new HashMap<Integer, String>();
		
		for(int i=0; i<tickets.size() ; i++)
		{
			Ticket ticket = tickets.get(i);
			String sightName = sightRepository.getSightName(ticket.getSight_id());
			System.out.println("sightId : " + ticket.getSight_id());
			System.out.println("sight Name : " + sightName);
			
			sightNameMap.put(
					ticket.getSight_id(), 
					sightName
			);
		}
		
		return sightNameMap;
	}
	
}
